#!/bin/bash

main_url=" -u imogo_ops:'ULumo$=av%(tFO' -H "HOST:os-manage.ops.imogo.com"  -k  https://211.151.133.53:8443/os-manage/scripts/get_linux_server_info.py -o get_linux_server_info.py"
fuc_url="  -u imogo_ops:'ULumo$=av%(tFO' -H "HOST:os-manage.ops.imogo.com"  -k  https://211.151.133.53:8443/os-manage/scripts/rms_functions_linux.py -o rms_functions_linux.py"
raid_url=" -u imogo_ops:'ULumo$=av%(tFO' -H "HOST:os-manage.ops.imogo.com"  -k  https://211.151.133.53:8443/os-manage/scripts/MegaCli-8.07.10-1.noarch.rpm -o  MegaCli-8.07.10-1.noarch.rpm"


ping 10.1.213.1 -c 3 &>/dev/null
if [ $? -eq 0 ]; then
    main_url='http://10.1.213.1:18088/server_info/get_linux_server_info.py -o get_linux_server_info.py'
    fuc_url='http://10.1.213.1:18088/server_info/rms_functions_linux.py  -o rms_functions_linux.py'
    raid_url='http://10.1.213.1:18088/server_info/MegaCli-8.07.10-1.noarch.rpm -o  MegaCli-8.07.10-1.noarch.rpm'
fi


yum install -y pciutils dmidecode lldpad lshw wget


mkdir -p /data/scripts
cd /data/scripts

http_code=`curl -s -w "%{http_code}" $main_url`
if [ "a$http_code" == "a200" ];then
    `curl -s $fuc_url`
    `curl -s $raid_url`
    /bin/rpm -ivh /data/scripts/MegaCli-8.07.10-1.noarch.rpm
    echo   "1 4 * * * /usr/bin/python /data/scripts/get_linux_server_info.py " >>  /var/spool/cron/root
else
  echo "Please contact Liang-Qi-Ming to check 211.151.133.53 iptables' setting "
  exit 1
fi
